home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / nivb / queue.frm < prev    next >
Text File  |  1995-05-07  |  7KB  |  219 lines

  1. VERSION 2.00
  2. Begin Form QueueForm 
  3.    Caption         =   "Queue Services Test"
  4.    ClientHeight    =   3960
  5.    ClientLeft      =   870
  6.    ClientTop       =   1530
  7.    ClientWidth     =   6000
  8.    Height          =   4365
  9.    Left            =   810
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   3960
  12.    ScaleWidth      =   6000
  13.    Top             =   1185
  14.    Width           =   6120
  15.    Begin Timer RescanTimer 
  16.       Interval        =   1000
  17.       Left            =   4200
  18.       Top             =   3360
  19.    End
  20.    Begin ListBox JobList 
  21.       FontBold        =   -1  'True
  22.       FontItalic      =   0   'False
  23.       FontName        =   "Courier"
  24.       FontSize        =   9.75
  25.       FontStrikethru  =   0   'False
  26.       FontUnderline   =   0   'False
  27.       Height          =   2370
  28.       Left            =   120
  29.       TabIndex        =   5
  30.       Top             =   360
  31.       Width           =   5775
  32.    End
  33.    Begin ComboBox QueueNameBox 
  34.       Height          =   288
  35.       Left            =   1200
  36.       TabIndex        =   3
  37.       Top             =   3600
  38.       Width           =   2412
  39.    End
  40.    Begin ComboBox ServerNameBox 
  41.       Height          =   288
  42.       Left            =   1200
  43.       Sorted          =   -1  'True
  44.       TabIndex        =   1
  45.       Top             =   3240
  46.       Width           =   2412
  47.    End
  48.    Begin CommandButton CloseButton 
  49.       Caption         =   "&OK"
  50.       Height          =   372
  51.       Left            =   4800
  52.       TabIndex        =   0
  53.       Top             =   3360
  54.       Width           =   972
  55.    End
  56.    Begin Label Label6 
  57.       Caption         =   "Active"
  58.       Height          =   252
  59.       Left            =   840
  60.       TabIndex        =   9
  61.       Top             =   120
  62.       Width           =   612
  63.    End
  64.    Begin Label Label5 
  65.       Caption         =   "Size (bytes)"
  66.       Height          =   252
  67.       Left            =   4800
  68.       TabIndex        =   8
  69.       Top             =   120
  70.       Width           =   1092
  71.    End
  72.    Begin Label Label4 
  73.       Caption         =   "Owner [Station #]"
  74.       Height          =   255
  75.       Left            =   1680
  76.       TabIndex        =   7
  77.       Top             =   120
  78.       Width           =   1695
  79.    End
  80.    Begin Label Label3 
  81.       Caption         =   "Job #"
  82.       Height          =   252
  83.       Left            =   120
  84.       TabIndex        =   6
  85.       Top             =   120
  86.       Width           =   732
  87.    End
  88.    Begin Label Label1 
  89.       Alignment       =   1  'Right Justify
  90.       Caption         =   "Queue:"
  91.       Height          =   252
  92.       Left            =   0
  93.       TabIndex        =   4
  94.       Top             =   3600
  95.       Width           =   1092
  96.    End
  97.    Begin Label Label2 
  98.       Alignment       =   1  'Right Justify
  99.       Caption         =   "File Server:"
  100.       Height          =   252
  101.       Left            =   0
  102.       TabIndex        =   2
  103.       Top             =   3240
  104.       Width           =   1092
  105.    End
  106. End
  107.  
  108. Sub CheckQueue ()
  109.     Dim queueName As String * 48
  110.     Dim jobInfo As JOB_STRUCT
  111.     Static jobNumbers(250) As Long
  112.     maxJobs& = 250
  113.     
  114.     JobList.Clear
  115.     queueName = String$(48, 0)
  116.     searchName = QueueNameBox.Text
  117.     ccode% = ScanBinderyObject(searchName, OT_PRINT_QUEUE, queueID&, queueName, oType%, oHasProps%, oFlag%, oSec%)
  118.  
  119.     ccode% = GetQueueJobList(queueID&, jobCount&, jobNumbers(0), maxJobs&)
  120.     If ((ccode% = SUCCESSFUL) And (jobCount& > 0)) Then
  121.         For job& = 0 To (jobCount& - 1)
  122.             ccode% = ReadQueueJobEntry(queueID&, jobNumbers(job&), jobInfo)
  123.             If (ccode% = SUCCESSFUL) Then
  124.                 clientName$ = String$(48, 0)
  125.                 ccode% = GetBinderyObjectName(jobInfo.clientIDNumber, clientName$, oType%)
  126.                 If (ccode% = SUCCESSFUL) Then
  127.                     ccode% = GetQueueJobsFileSize(queueID&, jobNumbers(job&), fileSize&)
  128.                     If (ccode% = SUCCESSFUL) Then
  129.                         out$ = Format$(jobNumbers(job&), "#########   ")
  130.                         If (jobInfo.serverIDNumber = 0) Then
  131.                             out$ = out$ + "N     "
  132.                         Else
  133.                             out$ = out$ + "Y     "
  134.                         End If
  135.                         clientName$ = Left$(clientName$, InStr(clientName$, Chr$(0)) - 1)
  136.                         out$ = out$ + Left$(clientName$, 20)
  137.                         out$ = out$ + "[" + Format$(jobInfo.clientStation) + "]"
  138.                         out$ = out$ + Space$(39 - Len(out$))
  139.                         out$ = out$ + Format(fileSize&, "############")
  140.                         JobList.AddItem out$
  141.                     End If
  142.                 End If
  143.             End If
  144.         Next job&
  145.     End If
  146. End Sub
  147.  
  148. Sub CloseButton_Click ()
  149.     Unload QueueForm
  150. End Sub
  151.  
  152. Sub Form_Load ()
  153.     For connID% = 1 To 8
  154.         'for each connection in workstation's file server name table
  155.         'get the table entry, then see if it's null
  156.         
  157.         fileServerName$ = String$(48, 0)
  158.         If (IsConnectionIDInUse(connID%) = 1) Then
  159.             GetFileServerName connID%, fileServerName$
  160.             ServerNameBox.AddItem fileServerName$
  161.         End If
  162.     Next connID%
  163.  
  164.     'get name of default file server for combo box
  165.     fileServerName$ = GetDefaultFileServerName()
  166.     ServerNameBox.Text = fileServerName$
  167. End Sub
  168.  
  169. Sub Form_Unload (Cancel As Integer)
  170.     SetPreferredConnectionID (originalPrefConnID%)
  171. End Sub
  172.  
  173. Sub QueueNameBox_Change ()
  174.     CheckQueue
  175. End Sub
  176.  
  177. Sub QueueNameBox_Click ()
  178.     QueueNameBox_Change
  179. End Sub
  180.  
  181. Sub RescanTimer_Timer ()
  182.     CheckQueue
  183. End Sub
  184.  
  185. Sub ScanQueues ()
  186.     QueueNameBox.Clear
  187.     oID& = -1
  188.     Do
  189.         queueName$ = String$(48, 0)
  190.         ccode% = ScanBinderyObject("*", OT_PRINT_QUEUE, oID&, queueName$, oType%, oHasProps%, oFlag%, oSec%)
  191.         If (ccode% = SUCCESSFUL) Then
  192.             queueName$ = Left$(queueName$, InStr(queueName$, Chr$(0)) - 1)
  193.             QueueNameBox.AddItem queueName$
  194.         End If
  195.     Loop While (ccode% = SUCCESSFUL)
  196.  
  197.     If (QueueNameBox.ListCount > 0) Then QueueNameBox.Text = QueueNameBox.List(0)
  198. End Sub
  199.  
  200. Sub ServerNameBox_Change ()
  201.     ServerNameBox_Click
  202. End Sub
  203.  
  204. Sub ServerNameBox_Click ()
  205.     prefServer$ = ServerNameBox.Text
  206.     
  207.     ccode% = GetConnectionID(prefServer$, connID%)
  208.     If (ccode% = SUCCESSFUL) Then
  209.         SetPreferredConnectionID (connID%)  'tell which file server to send
  210.                                             'requests to
  211.         Screen.MousePointer = 11
  212.         ScanQueues                          'then go scan its bindery for queue objects
  213.         Screen.MousePointer = 0
  214.     Else
  215.         MsgBox "Unable to get connection ID of server " + prefServer$, MB_OK, "Error"
  216.     End If
  217. End Sub
  218.  
  219.